package com.fish.yssb.ui.page.util;

import android.util.Base64;

import com.fish.yssb.app.BaseApp;
import com.fish.yssb.data.model.LoginUser;
import com.fish.yssb.db.RealmDb;
import com.fish.yssb.db.bean.LogInfoTable;
import com.fish.yssb.db.bean.UserInfoTable;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;


public class LogUtil {

    public static void addLog(String title,String content)
    {
        LogInfoTable info = new LogInfoTable();

        long lTime = System.currentTimeMillis();

        String date = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss").format(
                new Date());
        info.setContent(content);
        info.setL_time(lTime);
        info.setTitle(title);
        info.setTime(date);

        final LoginUser user = BaseApp.getInstance().user;

        if(user!=null && !"".equalsIgnoreCase(user.getUserName())) {

            info.setOpertioner(user.getUserName());


            ArrayList<LogInfoTable> list = new ArrayList<>();
            list.add(info);
            RealmDb.getInstance().insertRealmObjects(list);
        }
    }

}

